﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseEntities;
using BussinessLogic;

namespace ATMSystem_G5_HaUI
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DefaultControl.Visible = true;
            DefaultValidCardFail.Visible = false;
            DefaultValidPIN.Visible = false;
            DefaultValidPINFail.Visible = false;
        }

        protected void btnInsertCard_Click(object sender, EventArgs e)
        {
            CheckCard();
        }

        public void CheckCard()
        {
            Card card = new Card();
            card.CardNo = txtCard.Text;
            if (ValidationLogic.ValidCard(card) == true)
            {
                Session["CardNo"] = txtCard.Text;
                DefaultControl.Visible = false;
                DefaultValidCardFail.Visible = false;
                DefaultValidPIN.Visible = true;
                DefaultValidPINFail.Visible = false;
            }
            else
            {
                Session["CardNo"] = "";
                DefaultControl.Visible = false;
                DefaultValidCardFail.Visible = true;
                DefaultValidPIN.Visible = false;
                DefaultValidPINFail.Visible = false;
            }
        }
    }
}